From 497515e5008f5c7a6279233b5f47afbb68f9c5cb Mon Sep 17 00:00:00 2001 From: Jun Zhu Date: Thu, 16 Sep 2010 17:49:43 +0100 Subject: [PATCH] libxl: Clear device-model info when destroying an HVM domain with stubdom. Signed-off-by: Jun Zhu Signed-off-by: Ian Jackson --- tools/libxl/libxl.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 5e5c482347..32cfc7cea4 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -899,21 +899,25 @@ static int libxl_destroy_device_model(libxl_ctx *ctx, uint32_t domid) } LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Device model is a stubdom, domid=%d\n", stubdomid); ret = libxl_domain_destroy(ctx, stubdomid, 0); - goto out; + if (ret) + goto out; + } else { + ret = kill(atoi(pid), SIGHUP); + if (ret < 0 && errno == ESRCH) { + LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Device Model already exited"); + ret = 0; + } else if (ret == 0) { + LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Device Model signaled"); + ret = 0; + } else { + LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "failed to kill Device Model [%d]", + atoi(pid)); + ret = ERROR_FAIL; + goto out; + } } xs_rm(ctx->xsh, XBT_NULL, libxl__sprintf(&gc, "/local/domain/0/device-model/%d", domid)); - ret = kill(atoi(pid), SIGHUP); - if (ret < 0 && errno == ESRCH) { - LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Device Model already exited"); - ret = 0; - } else if (ret == 0) { - LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Device Model signaled"); - ret = 0; - } else { - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "failed to kill Device Model [%d]", - atoi(pid)); - } out: libxl__free_all(&gc); return ret; -- 2.30.2